home *** CD-ROM | disk | FTP | other *** search
/ CD Ware Multimedia 1995 May / cd Ware (Juegos) Epimundo.iso / DOS / TOOLS / STARTREK.ZIP / CHAPTER.001 < prev    next >
Encoding:
Text File  |  1989-05-15  |  53.8 KB  |  1,057 lines

  1.         Chapter1 page 1 STARTREK THE COMPUTER PROGRAM By Joe Kasser
  2.  
  3.  
  4.  
  5.              CHAPTER 1
  6.  
  7.  
  8.         1.0 Making Friends With Your Computer
  9.  
  10.              For some reason, when most people first meet computers  they 
  11.         are  afraid of them.  If they sit down at the keyboard they  tend 
  12.         to freeze up.   Visions of the computer running amok and  causing 
  13.         tremendous  amounts  of destruction appear in their  minds.  Well 
  14.         just  take  a  look at one.  Does it look fierce?   It  may  look 
  15.         complicated  but  it certainly doesn't look  terrifying.    Young 
  16.         children  given  the  chance  will spend  hours  pecking  at  the 
  17.         keyboard, so why should such a device inspire fear or feelings of 
  18.         inadequacy in adults. There is absolutely no reason to be  afraid 
  19.         of  it.   First  of  all, it is completely  benign.   It  has  no 
  20.         feelings  at all.  It is an inanimate object. You can't hurt  its 
  21.         feelings  even if you physically assault it with a  hammer,  blow 
  22.         torch  or other instrument of destruction.  You may  destroy  it, 
  23.         but you definitely won't hurt its feelings.
  24.  
  25.              The computer can be likened to an unfinished being.  It  has 
  26.         been   created   (built)  and  is  complete.  It   now   requires 
  27.         instructions to perform any task.  These instructions are  called 
  28.         computer  programs or software, and the act of  putting  together 
  29.         these instructions is called programming.
  30.  
  31.              Once a program is put into the computer it "comes to  life".  
  32.         It can now do something.  That something is almost anything  that 
  33.         the human mind can conjure up.  The computer can play a game, can 
  34.         control  what ever is plugged into it, can teach, can in fact  do 
  35.         what ever its instructions tell it to do.
  36.  
  37.              The first thing to remember is that the computer always does 
  38.         what  it is told to do.  That means for example if you are  doing 
  39.         the  programming, that the computer does what you tell it to  do, 
  40.         which  is not necessarily the same thing as what you want  it  to 
  41.         do.   If you make a mistake in instructing the computer,  how  is 
  42.         it supposed to know what you meant to tell it?
  43.  
  44.              The  best  way  to learn how to tell it to  do  things  (ea. 
  45.         learning  to program it) is to work with it.    Thus  first  read 
  46.         the  books that come with the machine that tell you what it  does 
  47.         and  how to use it.   Then try and read a book that someone  else 
  48.         has  written  about the machine that explains how to  use  it  in 
  49.         greater   detail   than  the  documentation   supplied   by   the 
  50.         manufacturer.  You may then be ready to have a go at it yourself.
  51.  
  52.              Once  you have decided to buy a computer make  friends  with 
  53.         it.  In fact even if you haven't yet decided to buy one, its  not 
  54.         a  bad idea to make friends with one.  Go to a computer store  or 
  55.         the home of a friend who has one, sit down in front of the  thing 
  56.         and  play a few games.  Games are the best method of  introducing 
  57.         the beginner to the computer.
  58.  
  59.  
  60.  
  61.         Copyright (c) Joe Kasser 1989
  62.  
  63.  
  64.  
  65.  
  66.  
  67.         Chapter1 page 2 STARTREK THE COMPUTER PROGRAM By Joe Kasser
  68.  
  69.  
  70.              First  familiarize  yourself  with using  the  computer,  by 
  71.         playing with it.  You can do an awful lot with a computer without 
  72.         knowing the first thing about programming.  Applications packages 
  73.         abound.   Apart from the myriads of games there are many  serious 
  74.         packages  such  as  spread sheet  calculators,  word  processors, 
  75.         custom  packages  for  various professions  such  as  doctors  or 
  76.         dentists, and financial and other business programs.  Each  comes 
  77.         with its own documentation that explains how to use the software.  
  78.         You  only need to get involved with programming if you intend  to 
  79.         write  your own software or customize existing software  to  your 
  80.         requirements.
  81.  
  82.              When getting involved with programming start by typing  up a 
  83.         program  from a book or a magazine.  If you don't understand  the 
  84.         programming language, don't try to follow what is happening, just 
  85.         concentrate on not making any mistakes.  You will become familiar 
  86.         with  the jargon by working with it.  The terms will  enter  your 
  87.         sub-conscious and you will slowly learn what they mean.  When you 
  88.         type  in a program, save what you have entered every  few  lines.  
  89.         If  you  are working with cassettes play back the  cassette  from 
  90.         time  to time to verify that the recorder is  adjusted  properly.  
  91.         There are few things more frustrating than spending hours working 
  92.         at the machine only to lose the result due to a power failure  or 
  93.         bad  disk/cassette  save operation.  Once you  have  entered  the 
  94.         complete  program  into the machine, save it, then  have  someone 
  95.         else  help  you verify the typing by reading the listing  as  you 
  96.         check  the screen copy.  It is best to work from the end  of  the 
  97.         listing  back to the beginning if you can, so that you  will  not 
  98.         tend  to follow the "story" and anticipate what is  coming  next.  
  99.         Edit  any mistakes out of the program, save the verified  version 
  100.         and  then run the program.  The first time around several  things 
  101.         may happen including
  102.  
  103.         1)   the program performs as the author said it would,  
  104.  
  105.         2)   the program does weird and wonderful things approximating to 
  106.              what the author promised it would,
  107.  
  108.         3)   the computer displays error messages,
  109.  
  110.         4)   a combination of 2) and 3) occurs.
  111.  
  112.              In  the  event  that the computer fails to  perform  as  the 
  113.         author  said it would, recheck the program against  the  original 
  114.         magazine or book listing. If the program is written in BASIC  and 
  115.         you  get an error message of the type SYNTAX ERROR AT LINE  .....  
  116.         the computer is telling you that you have made a typing error  in 
  117.         line  ....  .  If the program has somehow been corrupted,  reload 
  118.         it, reverify the listing and try again.  If you still can't  find 
  119.         anything  wrong  then in the case of a magazine article  you  can 
  120.         either  hopefully  wait for a correction to be  published  a  few 
  121.         months later or try and find the error yourself.  For that  "User 
  122.         groups"  and computer clubs are very handy, because they  include 
  123.         people  who  have the same computer that you do and  may  know  a 
  124.         little more about it than you.  In fact it is advisable to try to 
  125.  
  126.  
  127.         Copyright (c) Joe Kasser 1989
  128.  
  129.  
  130.  
  131.  
  132.  
  133.         Chapter1 page 3 STARTREK THE COMPUTER PROGRAM By Joe Kasser
  134.  
  135.  
  136.         talk  about the program before you even begin to type it  up  for 
  137.         you  may find someone in the User group or club who  has  already 
  138.         typed it up and gotten it working.  The procedure of getting  the 
  139.         program  working by taking out the errors (known in the trade  as 
  140.         "bugs")  is  called  de-bugging the program.  You  will  then  be 
  141.         forewarned  as what to do to get the program to work,  or  better 
  142.         still be supplied with a cassette or disk for your personal  use, 
  143.         saving you the bother of typing the thing up yourself.
  144.  
  145.              Once  the program is working correctly (more or less),   you 
  146.         are  ready to start modifying the program.   Get hold of  a  book 
  147.         that describes the programming language that you are working with 
  148.         so  that  you  can use it as a  reference  book  and  dictionary.  
  149.         Dissect the program to see what the author made the computer  do.  
  150.         See  how  the idea for the game was translated  into  a  computer 
  151.         program.   Trace the flow of the program and make small  changes.  
  152.         For example, change the color of the display;  change the dialog;  
  153.         as  you  perform  these small modifications  you  will  build  up 
  154.         confidence  in  yourself.  You are now instructing  the  machine.  
  155.         You  are taking over from the original programmer and are  making 
  156.         it  perform to your wishes. You are becoming a programmer.   When 
  157.         you have played with other people's programs for long enough  the 
  158.         time will come when you are ready to write your own program.
  159.  
  160.              All computer applications are limited by either hardware  or 
  161.         software. Control applications may be limited by the input/output 
  162.         (i/o)  capabilities of the machine, games may be limited  by  the 
  163.         amount of memory in it, graphic capabilities are limited by  both 
  164.         the resolution of the screen, the colors available and the  speed 
  165.         that the computer can update the screen.
  166.  
  167.              The first generation of computer games were limited in  this 
  168.         manner.   In  the  early days of  personal  computers,  the  only 
  169.         terminal available was a teletypewriter.  This was a slow machine 
  170.         which printed capital letters on paper.  This type of machine  is 
  171.         still used in TELEX applications.  The computing power was  there 
  172.         but  the  graphics i/o capability wasn't.  The first  games  were 
  173.         thus  mostly some sort of simulation games with a minimal  amount 
  174.         of  i/o.   Video displays and CRT terminals soon  followed.   The 
  175.         same  technology that brought us the video displays also  allowed 
  176.         for  video games.  At first these games were dumb, namely  tennis 
  177.         or ping-pong. then as the technology improved, games and personal 
  178.         computers also improved.
  179.  
  180.              The  following generation of computers were designed  mainly 
  181.         as  game  playing  machines  and  incorporated  relatively   high 
  182.         resolution  color  graphics capability.   The  lowest  resolution 
  183.         machines  were  those  designed to work into  the  antenna  of  a 
  184.         conventional television receiver.  These machines made real  time 
  185.         action  games  available in the home and have proved to  be  very 
  186.         popular.  Higher resolution plug in add on's and  video  monitors 
  187.         added  more and more capacity to the machines and  as  technology 
  188.         progresses  games  became  and  will  become  more  complex   and 
  189.         sophisticated,  the i/o interface will become better,  more  "on-
  190.         line"  memory  will  become available and  greater  realism  will 
  191.  
  192.  
  193.         Copyright (c) Joe Kasser 1989
  194.  
  195.  
  196.  
  197.  
  198.  
  199.         Chapter1 page 4 STARTREK THE COMPUTER PROGRAM By Joe Kasser
  200.  
  201.  
  202.         become possible.
  203.  
  204.              The  simulation  games were superseded by the  action  games 
  205.         which required some degree of co-ordination yet little in the way 
  206.         of  thought.  In the current generation of simulation games,  the 
  207.         game is programmed about a behavior model.  In this book we shall 
  208.         discuss  a  Simulation, the theory behind it and  the  techniques 
  209.         that  can  be  used  to translate the  simulation  model  into  a 
  210.         workable and enjoyable game.
  211.  
  212.              The  computer is dumb.  It does exactly what you tell it  to 
  213.         do.  Not only that, you have to tell it in detail how to do  what 
  214.         you want it to do.  There is no point in telling the computer  to 
  215.         "rule  the world", you have to tell it in detail how to build  up 
  216.         armies,  cause subversion in other countries, fight  battles  and 
  217.         then  set  up your world government.   You may ask  what  is  the 
  218.         point  of having a computer, if it has to be told  everything  in 
  219.         detail.   If  you  are  going  to  have  to  explain  each  point 
  220.         meticulously,  you  may as well do the job yourself.    Well  the 
  221.         computer  is best doing repetitive tasks.  If the calculation  is 
  222.         to  be done once, use a pocket calculator, if it is going  to  be 
  223.         done many times, use a personal computer.
  224.  
  225.              The  computer has to be instructed by a human  being.   When 
  226.         there  is  a mistake in a bill or account statement, it  is  very 
  227.         unlikely  that  the computer is at fault no matter what  you  are 
  228.         told.  The fault is most probably human. The mistake is either in 
  229.         the program or more probably the mistake was made at the time  of 
  230.         the entry of data into the computer.  If the person entering  the 
  231.         amount  of  your  payment into the computer makes  a  mistake  by 
  232.         entering  the  wrong amount and the mistake is  not  caught,  the 
  233.         program will grind on on its way and will send you messages based 
  234.         on the faulty input data, because after all, how was it  supposed 
  235.         to  know.    Amongst computer professionals  this  phenomenon  is 
  236.         known as "garbage - in, garbage - out" (GIGO).
  237.  
  238.              Computer  languages are the means by which  people  instruct 
  239.         computers to perform tasks.  Any person who wishes to control the 
  240.         operation  of a computer rather than just to communicate with  it 
  241.         thus  has to learn a programming language.  Learning  a  computer 
  242.         language  is  easier than learning a foreign  language;  such  as 
  243.         French,  Spanish,  Japanese  or  Hebrew  because  in  a  computer 
  244.         language  a  word  or expression has only one  meaning,  and  the 
  245.         computer does exactly what it is told to do.
  246.  
  247.              Learning  a language is a chore unless you remember that  it 
  248.         is  really a means to an end.  The end is the task that you  want 
  249.         the  computer  to do, the means is the language that you  use  to 
  250.         tell the computer how to do the task. If you can define the  task 
  251.         first,  then use the language to make the computer  perform  that 
  252.         task,  and you are really interested in that task,  learning  the 
  253.         language will become a by-product of the operation.
  254.  
  255.              Talking to the computer in a language that it understands is 
  256.         called  programming.  Programming is the art of writing  programs 
  257.  
  258.  
  259.         Copyright (c) Joe Kasser 1989
  260.  
  261.  
  262.  
  263.  
  264.  
  265.         Chapter1 page 5 STARTREK THE COMPUTER PROGRAM By Joe Kasser
  266.  
  267.  
  268.         or sequences of instructions for the computer to perform.   Being 
  269.         able  to  write programs is not the same as being able  to  write 
  270.         good  programs.   There  are many people who  earn  their  living 
  271.         writing computer programs.  There are other people who earn their 
  272.         living   fixing   up  programs  written  by   other   so   called 
  273.         "programmers".   Computer programming is easy.  Any idiot can  do 
  274.         it.   Good computer programming is difficult but can  be  learnt.  
  275.         If  you are learning your first computer language, you  are  also 
  276.         learning  programming,  which is not the same thing.   There  are 
  277.         many programmers who know FORTRAN or BASIC yet do not know a word 
  278.         of  FORTH.   There  are people who know many  languages  yet  are 
  279.         terrible  programmers, so if this is your introduction to  BASIC, 
  280.         you  are also learning programming as well as BASIC and it is  as 
  281.         well  to differentiate between the two.  The habits you form  now 
  282.         will govern your programming ability from now on, so be sure that 
  283.         they are the correct ones.   
  284.  
  285.              Computer programs operate on three categories of data.  They 
  286.         are  constants, variables and parameters.  The data elements  may 
  287.         be  simple  or complex and stored as single items or as  rows  or 
  288.         arrays of elements.
  289.  
  290.              A  constant is a fixed value that never changes, such as  1, 
  291.         2, 88, 1023 etc.  
  292.  
  293.              A  variable is a data element that changes its  value  while 
  294.         the  program  runs.  It is usually referenced by a name  such  as 
  295.         APPLE or A0.  The address of the variable is the location that it 
  296.         is  stored in memory, the contents of the location are the  value 
  297.         assigned to the variable.
  298.  
  299.              A  parameter has a value that is fixed for a particular  run 
  300.         of  the program.  For example, in space war games, the number  of 
  301.         enemy  vessels  at the start of each game may  be  different  but 
  302.         constant  for  the  particular game.  That  number  can  thus  be 
  303.         considered as a parameter.
  304.  
  305.              Since most BASIC interpreters process constants  differently 
  306.         to the way they operate on variables, it is usually advisable  to 
  307.         store constants as parameters. Thus for example, instead of using 
  308.         0.1  as a constant if it will be used many times, use  P1  (point 
  309.         one)  as  a  parameter  equal to  0.1   Values  are  assigned  to 
  310.         variables and parameters using the LET statement in BASIC such as 
  311.         in the statement
  312.                                   LET P1 = 0.1
  313.              Alternatively,  you will also meet the LET statement in  the 
  314.         format
  315.                                  LET A0 = A0 + 5
  316.              Here, the statement means, take the current value stored  in 
  317.         the variable A0, add 5 to it and save the result (in the location 
  318.         addressed  as) A0.  If you are at all familiar with algebra,  you 
  319.         will have noticed right away that there was something wrong  with 
  320.         the equation.  You are correct, the statement is not an equation, 
  321.         it is an expression.  It could have been expressed as 
  322.                                LET A0 +  5 -> A0.
  323.  
  324.  
  325.         Copyright (c) Joe Kasser 1989
  326.  
  327.  
  328.  
  329.  
  330.  
  331.         Chapter1 page 6 STARTREK THE COMPUTER PROGRAM By Joe Kasser
  332.  
  333.  
  334.  
  335.              Data comes in a number of formats.  If the format is numeric  
  336.         (ea.  it is numbers), the data can be integer or floating  point. 
  337.         Integer  numbers  do  not have a decimal  part.  They  are  whole 
  338.         numbers,  floating point numbers have decimal parts.  Example  of 
  339.         floating point numbers are 1.652, 12.13, 0.003, and 567.8.   Note 
  340.         the  different  position  of the decimal point  in  each  of  the 
  341.         numbers, namely it floats around.
  342.  
  343.              An  other  form of data is text material  in  ASCII  format.  
  344.         These are words that make up headings and titles, such as  "SHORT 
  345.         RANGE  SENSORS" or "PHASERS".  In BASIC such material are  called 
  346.         "strings"  because  they  consist of strings  of  letters  joined 
  347.         together.  Variables, constants or parameters containing  strings 
  348.         of  text are called string variables, string constants or  string 
  349.         parameters.   They  are identified by a dollar  sign  termination 
  350.         (pronounced "string") such as A$ ("A string") or D$ ("D string"), 
  351.         and can be treated just like regular numeric variables, thus 
  352.  
  353.         LET A$ = "SHORT RANGE SENSORS" sets up the contents of the string 
  354.         variable  A$ as SORT RANGE SENSORS.  Quotation marks have  to  be 
  355.         used  in BASIC to define the start and the end of the  string  of 
  356.         characters.
  357.  
  358.              Variables   can  be  stored  individually  or   in   arrays.  
  359.         Individual variables can be named, such as APPLE, PEAR, ORANGE or 
  360.         BANANA.  An array can be considered as a group of variables  that 
  361.         can   be  referenced  with  respect  to  some  kind   of   common 
  362.         denominator.   For  example, if we had an array  named  FRUITBOWL 
  363.         then  each item in the array can be a separate fruit, and can  be 
  364.         referenced with respect to the FRUITBOWL as FRUITBOWL(1) for  the 
  365.         first element, FRUITBOWL(9) for the ninth, etc.
  366.  
  367.              An  ideal task for the beginner to learn a language on is  a 
  368.         simulation  game  which is written around the computer  that  the 
  369.         beginner  has  available.  For in that case,  there  is  complete 
  370.         control  of all inputs and outputs,   This kind of game in  which 
  371.         the player makes decisions based on the information available  to 
  372.         him  or  her  available at the time), can  be  made  sufficiently 
  373.         sophisticated  and complex so as to make writing it  an  adequate 
  374.         challenge for anybody.
  375.  
  376.              The techniques used in writing a good game are the same that 
  377.         programmers use in professional activities.  Writing a good  game 
  378.         poses  a  challenge that allows you to develop  good  habits  and 
  379.         techniques  for  programming  and  also allows  you  to  learn  a 
  380.         language in an interesting manner.  By taking an orderly approach 
  381.         to the game design, complex operations may be clearly  understood 
  382.         and  converted  to  computer  code with the  aid  of  a  language 
  383.         reference manual, irrespective of the language being used.
  384.  
  385.  
  386.         1.1 Defining the Game or Task
  387.  
  388.              Pick  a task that interests you.  you can invent a new  game 
  389.  
  390.  
  391.         Copyright (c) Joe Kasser 1989
  392.  
  393.  
  394.  
  395.  
  396.  
  397.         Chapter1 page 7 STARTREK THE COMPUTER PROGRAM By Joe Kasser
  398.  
  399.  
  400.         or  rewrite  an existing one.  If you are familiar  with  a  game 
  401.         written  in one language such as BASIC, and are learning  another 
  402.         such  as  FORTH,  examining  the  different  approaches  used  by 
  403.         programs written in two languages to achieve the same end results 
  404.         will be educational in itself.
  405.  
  406.              If you plan to interest others in playing your game once you 
  407.         have finished it, there are a number of factors to be considered.  
  408.         The  first  one  is the ease of learning how to  play  the  game.  
  409.         There  should be no need for someone to sit down and study a  176 
  410.         page  manual (no matter how well written) in order to  learn  the 
  411.         rules.   If  you  can model real life, a  well  known  television 
  412.         series,   a  best  selling  book  or  some  other  widely   known 
  413.         environment,  your game will have a wider appeal than if you  had 
  414.         invented  the game from scratch.  The disadvantage of basing  the 
  415.         game  on  an  existing  work  of fiction  is  that  it  has  been 
  416.         copyrighted  and  depending  on what you plan  to  do  with  your 
  417.         finished  product, you may have to enter into  negotiations  with 
  418.         the owner of the copyright.  If you invent your own game, or your 
  419.         own  situations,  try and use characters or situations  that  are 
  420.         familiar  to the players before they sit down to play  the  game.  
  421.         If  you  cannot do this, then make the options available  to  the 
  422.         player self evident.
  423.  
  424.              The  second factor involved is the degree of  complexity  or 
  425.         sophistication of the game.  The more complex it is, the  greater 
  426.         the enjoyment in playing it, however that also means that it will 
  427.         be  more  difficult  to  learn the rules.  There  is  a  tradeoff 
  428.         involved  between  "getting them interested"  and  "keeping  them 
  429.         interested".
  430.  
  431.              Another  factor is realism.  the player has to believe  that 
  432.         the  game  takes place in a logical and  believable  environment.  
  433.         Don't  create  an  absurd or unbelievable  situation  and  expect 
  434.         anyone to play your game more than once.  Books, films and  plays 
  435.         are   entertainment.    A  computerized   game   is   interactive 
  436.         entertainment.   You, the game writer create the  background  and 
  437.         set  up the rules for the consequences of any action.   you  then 
  438.         let the player wander through your creation, and each playing  of 
  439.         the game will be different.  It is this difference that poses the 
  440.         challenge and makes them come back again and again.
  441.  
  442.              Embellishments  or  "bells and whistles" can  leave  a  very 
  443.         positive  impression on your game players.  How many  times  have 
  444.         you heard said about a movie that "the plot was terrible, but the 
  445.         special effects were great".  Put as many special effects as  you 
  446.         can within reason into your game.
  447.  
  448.              The first step in writing the program is coming up with  the 
  449.         idea.  What should the program do?  What do you want the  program 
  450.         to  do?   A game is a good first time program  because  you  have 
  451.         total  control over all aspects of the task.  You can decide  the 
  452.         rules.   You can decide on the i/o.  You don't have to  build  or 
  453.         buy  a special interface for the computer to talk to the  outside 
  454.         world.  Your program can be self contained.
  455.  
  456.  
  457.         Copyright (c) Joe Kasser 1989
  458.  
  459.  
  460.  
  461.  
  462.  
  463.         Chapter1 page 8 STARTREK THE COMPUTER PROGRAM By Joe Kasser
  464.  
  465.  
  466.  
  467.              Once  you  have  developed the idea  write  it  down.   This 
  468.         becomes the specification for the program.  It should describe in 
  469.         words  what  the  program  is to do.   It  does  not  necessarily 
  470.         describe  how  it will do the job.   The  specification  is  thus 
  471.         independent of the programming language.
  472.  
  473.              The  next stage is to decide on the language.  The  decision 
  474.         may  be made for you, for example if the personal computer  comes 
  475.         with a built in language when you purchase it, and you don't have 
  476.         any  others,  that is the one you will use.   Most  computers  at 
  477.         this  time  come with a dialect of BASIC built into  them.    The 
  478.         vast  majority of computer programs can be written in almost  any 
  479.         computer  language.  Some programs however are optimally  written 
  480.         in  languages designed for particular applications.  FORTRAN  for 
  481.         example  optimizes mathematical computations, COBOL was  designed 
  482.         for business applications, BASIC for teaching programming,  FORTH 
  483.         for process control, and so on.
  484.  
  485.              To repeat, a  game is an ideal task for learning a  computer 
  486.         language.  In defining the game you set up all the conditions and 
  487.         constraints,  you  are  bound only by your  imagination  and  the 
  488.         physical  limitations  of the computer.  (There is  no  point  in 
  489.         writing  a  graphic shooting gallery game if the  only  operating 
  490.         interface you have is a teletypewriter).
  491.  
  492.              Once  the  task is defined, you know what  the  computer  is 
  493.         going  to do.  The next stage is to decide how it is going to  do 
  494.         it.    The  complete task must be broken down into  a  number  of 
  495.         sequential  steps.   How  detailed these steps have to  be  is  a 
  496.         function  of  what level of language is being used to  write  the 
  497.         program.  For  example, adding two variables  together  could  be 
  498.         written in BASIC as 
  499.                                LET  A0  = A1 + A2
  500.         which instructs the computer to add together the values  assigned 
  501.         to  the  variables  A1 and A2 then to store  the  result  in  the 
  502.         variable  A0.   A  similar  sequence  written  in  8080  assembly 
  503.         language could look something like
  504.  
  505.              LDA  A1   ;LOAD THE CONTENTS OF A1 INTO THE ACCUMULATOR
  506.              LXI  H,A2 ;POINT THE H AND L REGISTERS AT A2
  507.              ADD  M    ;ADD THEM
  508.              STA  A0   ;AND SAVE THE RESULT IN MEMORY AT LOCATION A2
  509.  
  510.         In  the low level assembly language, you have to assume that  the 
  511.         computer  knows  nothing.   In order to have  it  add  those  two 
  512.         values,  not only do you have to tell it to add the numbers,  but 
  513.         you first  have to tell it where they  are stored in memory, then 
  514.         you have to tell it to fetch them from memory, add them  together 
  515.         and where to store the result.  In the higher level language, you 
  516.         don't  care  where  the data are stored in memory,  you  let  the 
  517.         computer assign memory space to the variables, and all you do  is 
  518.         tell it to add them.
  519.  
  520.              Earlier   we  saw  that  the  computer  is  ignorant   until 
  521.  
  522.  
  523.         Copyright (c) Joe Kasser 1989
  524.  
  525.  
  526.  
  527.  
  528.  
  529.         Chapter1 page 9 STARTREK THE COMPUTER PROGRAM By Joe Kasser
  530.  
  531.  
  532.         instructed  otherwise. How then can the computer know  by  itself 
  533.         where to store those numbers?  A statement such as LET A0 = A1  + 
  534.         A2 only tells the computer what to do with A0, A1 and A2, it says 
  535.         nothing about where they are located in memory.
  536.  
  537.              In order to understand this we have to take a brief look  at 
  538.         the  internal  hardware of the computer as shown in  figure  1.1.  
  539.         The majority of the hardware consists of memory which is used  to 
  540.         store  both instructions (programs) and data.   The  instructions 
  541.         are  carried  out  in the Arithmetic - Logic Unit  (ALU)  of  the 
  542.         Central  Processing  Unit  (CPU). The interface to  the  user  is 
  543.         located in the i/o module.
  544.  
  545.              When the computer is first turned on, the internal circuitry 
  546.         of the hardware dictates the memory location that will be read as 
  547.         the  first  instruction.   Each time that  the  microcomputer  is 
  548.         "powered  up", that location will be assumed to contain the  fist 
  549.         instruction.   In the case of the 8080 or Z80, that  location  is 
  550.         the  first location of memory at an address of 0.   The  starting 
  551.         location for other microprocessors differs.   Most microcomputers 
  552.         contain  hardware read only memory (ROM) at the starting  address 
  553.         location or some other circuitry to fool the CPU into thinking it 
  554.         is  looking  at the starting address when it  is  really  looking 
  555.         elsewhere.   The actual task performed by the program in the  ROM 
  556.         at  the starting location differs in each machine.  In  some,  it 
  557.         may initialize a monitor program such as AMS-80, in others it may 
  558.         initialize  BASIC,  or  boot up a Floppy  Disc  Operating  System 
  559.         (DOS).
  560.  
  561.              Now consider what actually happens when when an  instruction 
  562.         is  carried  out.  At  the   micro  -  micro  level,  just  after 
  563.         initialization,  the  computer is going to carry  out  its  first 
  564.         instruction.  The first thing it does is fetch the first part  of 
  565.         the  instruction  from memory into the  Central  Processing  Unit 
  566.         (CPU).   The  hardware  in the CPU determines  the  type  of  the 
  567.         instruction  and then performs the remainder of the  instruction.  
  568.         Each instruction is divided up into a number of parts.  There  is 
  569.         the  fetch  cycle in which the instruction is moved  from  memory 
  570.         into  the CPU and then there is the execution cycle in which  the 
  571.         instruction  is  carried out.   The mechanism  to  perform  these 
  572.         functions  are  built into the hardware of the  machine  and  are 
  573.         known as the micro code. Different microprocessors have different 
  574.         micro  codes and thus also have different sets  of  instructions.  
  575.         There  are some special purpose microprocessors (usually  of  bit 
  576.         slice architecture) that allow you to define your own micro  code 
  577.         and thus your own basic instruction set.
  578.  
  579.              The  micro code operates on a set of bits called a byte.  If 
  580.         the  machine is an 8 bit machine it has an accumulator that is  8 
  581.         bits  wide, if it is a 16 bit machine it has an accumulator  that 
  582.         is  16 bits wide.  The byte in the accumulator is represented  in 
  583.         binary  (Base  2)  math  as a number.   For  our  convenience  as 
  584.         programmers,  these  binary  numbers  are  grouped  together  and 
  585.         represented  by Octal (Base 8) or Hexadecimal (Base  16)  values.  
  586.         An  example of such a number is 11000011 in Binary, 303 in  Octal 
  587.  
  588.  
  589.         Copyright (c) Joe Kasser 1989
  590.  
  591.  
  592.  
  593.  
  594.  
  595.         Chapter1 page 10 STARTREK THE COMPUTER PROGRAM By Joe Kasser
  596.  
  597.  
  598.         or  C3  in  hexadecimal notation.  The  CPU  works  with  digital 
  599.         signals  that only have "on" or "off" states, represented by a  0 
  600.         for "off" and a 1 for "on".  It is much more convenient to  refer 
  601.         to C3 00 F0 as an instruction than 11000011 00000000 11110000.
  602.  
  603.              If  memory is filled with binary numbers, how then does  the 
  604.         computer  know  which are instructions and which are  data?   The 
  605.         microcode  knows  how many bytes an instruction  requires.   That 
  606.         knowledge is built into the hardware as part of the  architecture 
  607.         of  the machine.  So once it has read and decoded the first  byte 
  608.         it  knows  what  is to follow.  The first byte is  known  as  the 
  609.         operation code (op code) because it defines what operation is  to 
  610.         be  performed.  Thus for example in 8080 code, a branch  or  jump 
  611.         instruction  that causes the program flow to continue  from  some 
  612.         location  other  than  the next one in the  sequence,  is  always 
  613.         followed by two bytes containing the address of that location.  
  614.  
  615.              The first few instructions in the start up ROM are in binary 
  616.         code.   Since  binary  code  even in  its  Octal  or  Hexadecimal 
  617.         representation is not easy to use for most programmers,  assembly 
  618.         language and assembler programs were invented. Assembly  language 
  619.         allows  us to refer to an instruction in a pseudo english  manner 
  620.         somewhat  symbolic  of  what the  instruction  really  does,  for 
  621.         example,  again in 8080 assembly language JMP means jump  (to  an 
  622.         other  instruction located somewhere else in memory),  MOV  means 
  623.         move  something  from one register to an other,  MVI  means  move 
  624.         something  (like a constant) immediately into a  register.    The 
  625.         assembler  also  allows us to refer to memory locations  by  name 
  626.         instead of by the address of the absolute location.
  627.  
  628.              Figure 1.2 is an example of a program listing made using  an 
  629.         assembler.  An editor program is first loaded into the  computer.  
  630.         This  is a (rudimentary) word processor that allows the  assembly 
  631.         language instructions to be stored in machine readable form.  The 
  632.         assembler is then invoked to convert the Assembly Language Source 
  633.         code  to a binary object code.   This object code is then  loaded 
  634.         into  memory and is then executed by the machine in  turn.   Note 
  635.         the  use  of comments after the instruction.  The format  of  the 
  636.         listing  is address location, hexadecimal representation  of  the 
  637.         object  code, assembly language (split into op code  and  numeric 
  638.         parts)  and  comments.  In 8080 assembly language,  the  comments 
  639.         have  to  be  preceded by a semi colon.  In  BASIC  comments  are 
  640.         preceded by a REM statement.  Comments are very important and are 
  641.         used  to explain why something was done in a  particular  manner.  
  642.         They  serve  two purposes: the first being to explain  to  others 
  643.         what  you did and how you did it, the second reason is to  remind 
  644.         you  of what you did when you come to make some modifications  to 
  645.         the program after some time has elapsed since you wrote it. 
  646.  
  647.              Writing   in  assembly  language  has   many   disadvantages 
  648.         including  the one that the programmer has to give very  detailed 
  649.         instructions  and has to keep track of the locations of  all  the 
  650.         data.   There  must be a better way, and  for  many  applications 
  651.         there is, and it is known as a high level language.
  652.  
  653.  
  654.  
  655.         Copyright (c) Joe Kasser 1989
  656.  
  657.  
  658.  
  659.  
  660.  
  661.         Chapter1 page 11 STARTREK THE COMPUTER PROGRAM By Joe Kasser
  662.  
  663.  
  664.         1.2 The high level language
  665.  
  666.              The  high level language of which BASIC is just one  example 
  667.         is itself a program that is a tool which allows the programmer to 
  668.         concentrate  on  telling  the computer what to  do.  In  assembly 
  669.         language, not only do you have to tell the CPU what to do and how 
  670.         to do it, but you also have to tell it where everything is.   The 
  671.         assembler  facilitates  the  job but the onus  is  still  on  the 
  672.         programmer.  The high level language on the other hand has  built 
  673.         into  it a lot of "where" information.  From now on,  when  using 
  674.         the high level language, if you define a variable such as  APPLE, 
  675.         the  language  will assign a memory location to  APPLE  and  some 
  676.         bytes  (space) to store data in that location.  Most versions  of 
  677.         BASIC  do not even require you to tell the computer that you  are 
  678.         going  to use APPLE as a variable until the first time  that  you 
  679.         actually use it.
  680.  
  681.              If we go back to the A0 = A1 + A2 example that was mentioned 
  682.         above, the full assembly language listing also has to include
  683.  
  684.         A0:  DS   1    ;DEFINE SPACE FOR 1 MEMORY LOCATION
  685.         A1:  DS   1    ;DEFINE SPACE FOR 1 MEMORY LOCATION
  686.         A2:  DS   1    ;DEFINE SPACE FOR 1 MEMORY LOCATION
  687.  
  688.              which  tells  the assembler to define the locations  of  the 
  689.         variables  and reserve one byte of memory to be  associated  with 
  690.         each of them.  If these pseudo instructions were not included  in 
  691.         the source code listing, the assembler would flag every reference 
  692.         to  A0,  A1 or A2 as an error (referencing  an  undefined  memory 
  693.         location).   The  use of the term pseudo instruction,  defines  a 
  694.         category of directives to the assembler, rather than instructions 
  695.         that are executed by the CPU.
  696.  
  697.              Consider now what happens when BASIC meets and processes the 
  698.         instruction  LET A0 = A1 + A2    which instructs the computer  to 
  699.         add together the values assigned to the variables A1 and A2  then 
  700.         to store the result in the variable A0.  BASIC first locates  the 
  701.         variable  A1  and A2 and adds their contents together.   It  then 
  702.         searches for and stores the result in the variable A0.  If A0 has 
  703.         not yet been defined, BASIC allocates space for it at this  time.  
  704.         The  programmer does not know where the variables are  stored  in 
  705.         memory and in most instances does not care.
  706.  
  707.              BASIC is available as an interpreter or as a compiler.   The 
  708.         interpreter  resides  in memory together with  the  program.   It 
  709.         sequentially interprets each line of program in turn,  converting 
  710.         it on the fly to binary object code and executing it. Since  each 
  711.         line of code is interpreted each time it is executed the  running 
  712.         speed of the program is relatively slow.  A compiler for BASIC on 
  713.         the  other hand performs an operation on the program  written  in 
  714.         BASIC  analogous  to the operation of an  assembler  on  assembly 
  715.         language  to  convert  it to an object code  module.   Since  the 
  716.         computer  then  executes  a compiled  binary  object  module  the 
  717.         execution time is speeded up.  
  718.  
  719.  
  720.  
  721.         Copyright (c) Joe Kasser 1989
  722.  
  723.  
  724.  
  725.  
  726.  
  727.         Chapter1 page 12 STARTREK THE COMPUTER PROGRAM By Joe Kasser
  728.  
  729.  
  730.              Programs  being  executed in the interpretive  mode  can  be 
  731.         interrupted  and  changed  at will in an  interactive  mode,  ea. 
  732.         debugged  "on  line".    Programs  that  are  compiled  and  then 
  733.         executed  have  to  go  through  an  editing  (of  the  program), 
  734.         compilation  and execution sequence and cannot be altered  during 
  735.         the   testing  session.   The  interpreter  is  thus  used   when 
  736.         developing  programs  for ease of debugging.   The  compiler  can 
  737.         then  be used to provide somewhat greater execution speed and  to 
  738.         make the code more difficult to disassemble by others if security 
  739.         of the source code is important.    Note that even when compiled, 
  740.         programs  written in high level languages always run slower  that 
  741.         the equivalent program written in assembly language.
  742.  
  743.              Computing  as you will find, more and more, is a balance  of 
  744.         trade-offs. The trade-off between assembly language and the  high 
  745.         level language is usually that of speed (execution time)  against 
  746.         ease of telling the computer what to do.  In most cases the speed 
  747.         of  execution  of a program written in a high level  language  is 
  748.         still  greater than the user needs.  There are however  instances 
  749.         when  not only must assembly language be used to  meet  execution 
  750.         speed  requirements,  but  the  actual  instructions  used   must 
  751.         themselves be chosen to comply with the same speed  requirements, 
  752.         because  different assembly language instructions have  different 
  753.         (numbers of machine cycles) execution times.
  754.  
  755.         1.3 Structuring Programs
  756.  
  757.              Good programs are well thought out, logical and  structured.   
  758.         The  are put together in a modular manner and structured so  that 
  759.         they  have a beginning, a middle and an ending.  This means  that 
  760.         much  thought  has  to  be applied before  the  program  is  even 
  761.         written.  BASIC is often thought of as an unstructured  language.  
  762.         That is not true.  BASIC is usually met for the first time in its 
  763.         interpretive incarnation.  That means that it is easy to sit down 
  764.         at  the computer, type in a few lines of a routine and  have  the 
  765.         computer  do something.   A few more lines are then added  to  do 
  766.         something else.  Later some more instructions are added,  linking 
  767.         the  first  two sets. More and more instructions  are  added  and 
  768.         linked  together  until  a program is  finished.   This  finished 
  769.         program is usually very unstructured because it contains numerous 
  770.         instructions  to  branch out of the sequence to  different  lines 
  771.         elsewhere  in  the listing.  There will be  forward  branches  to 
  772.         lines  still  to come, and backward branches to lines  that  have 
  773.         already appeared.
  774.  
  775.              As  a result of seeing numerous programs of this  kind,  the 
  776.         word  has  gotten out that BASIC does not allow  well  structured 
  777.         programs  to be written.   Balderdash! Programs written in  BASIC 
  778.         can be just as structured as those written in any other  language 
  779.         if you take care to do so.  That means don't just sit down at the 
  780.         machine  and  start typing.  Sit down with your  word  processor, 
  781.         first  define what the program is to do, then chart out the  flow 
  782.         of  the program, lastly sit down and enter it into the  computer.   
  783.         You then get small sections of it working and link them to  other 
  784.         sections  as you add them. However, since you have  flow  charted 
  785.  
  786.  
  787.         Copyright (c) Joe Kasser 1989
  788.  
  789.  
  790.  
  791.  
  792.  
  793.         Chapter1 page 13 STARTREK THE COMPUTER PROGRAM By Joe Kasser
  794.  
  795.  
  796.         the  program beforehand, you enter the various sections into  the 
  797.         computer in a logical manner and a structured program results.
  798.  
  799.         1.4 Flow Charts
  800.  
  801.              A  flow chart is a tool for keeping track of the flow  of  a 
  802.         program.   It  shows in outline form what is being done  and  how 
  803.         decisions affect the sequence of instructions.   
  804.  
  805.              The  operations  performed by a computer program  fall  into 
  806.         distinct  categories.  There are input/output  operations  (i/o), 
  807.         processing modules, decisions, etc.   Each can be represented  by 
  808.         a different shape on the flow chart as shown in figure 1.3.  Flow 
  809.         charts are graphic tools, since the computer is a digital  device 
  810.         most   suited  for  word  processing  and  other  non   graphical 
  811.         applications  here is a way of drawing flow charts using  a  word 
  812.         processor.     It is also designed to optimize top  down  program 
  813.         design and bottom up implementation.
  814.  
  815.              Figure  1.4a shows a typical extract from a flow chart.   At 
  816.         the top there is a test or choice.  Branching out from there  are 
  817.         two  blocks  that  contains tasks or  procedures  that  are  self 
  818.         contained sequences of some kind.  If the condition being  tested 
  819.         by  the  test block of the flowchart is met,  the  program  flows 
  820.         along  the YES branch and procedure B is performed.   Should  the 
  821.         test  fail, procedure A is carried out.  Both branches THEN  come 
  822.         together  and continue the program flow.  This flowchart  can  be 
  823.         represented as follows;
  824.  
  825.         CHOICE =?
  826.              YES  DO.PROCEDURE."B"
  827.              NO   DO.PROCEDURE."A"
  828.              THEN
  829.  
  830.         Note  that it is also descriptive of what is being done.   Figure 
  831.         1.4b  shows the same flow chart but the NO side is  missing.   In 
  832.         this example, there is no operation performed if the test  fails.  
  833.         This is written as
  834.  
  835.  
  836.         CHOICE =?
  837.              YES  DO.PROCEDURE."B"
  838.              THEN
  839.  
  840.         If  the  reverse  is true, namely nothing is  done  if  the  test 
  841.         passes,  but if it fails, a procedure is carried out as shown  in 
  842.         figure 1.4c, it can be written as
  843.  
  844.         CHOICE =?
  845.              NO   DO.PROCEDURE."A"
  846.              THEN
  847.  
  848.         the  indentation makes the written chart easier to read.  A  more 
  849.         complex  extract  of a flow chart is shown in figure  1.5.   Here 
  850.         there  are four procedures (A,B,C and D) and two choices  (1  and 
  851.  
  852.  
  853.         Copyright (c) Joe Kasser 1989
  854.  
  855.  
  856.  
  857.  
  858.  
  859.         Chapter1 page 14 STARTREK THE COMPUTER PROGRAM By Joe Kasser
  860.  
  861.  
  862.         2).  This flow chart can be written as follows
  863.  
  864.         CHOICE.1 =?
  865.              YES  (1)  DO.PROCEDURE."B"
  866.                        CHOICE.2 =?
  867.                        YES  (2)  DO.PROCEDURE."D"
  868.                        NO   (2)  DO.PROCEDURE."C"
  869.                        THEN (2)
  870.              NO   (1)  DO.PROCEDURE."A"
  871.              THEN (1).
  872.  
  873.         Another section of a flow chart is shown in figure 1.6.  This  is 
  874.         an  example of a loop in which something is done (Procedure  "A") 
  875.         as  long as the value of the variable I has not counted  down  to 
  876.         zero.  This can be written as
  877.  
  878.         SET.VALUE.OF."I"
  879.         LOOP (on I)
  880.         +    DO.PROCEDURE."A"
  881.         +    DO.PROCEDURE."B"
  882.         +    DO.PROCEDURE."C"
  883.         LOOPEND.
  884.  
  885.         The  "+"  is  used  on the first line  of  the  chart  statements 
  886.         referencing  operations  or procedures within a loop  to  signify 
  887.         that a loop is in progress.  There may or may not be the need for 
  888.         the  programmer  to  test  the value of  the  loop  counter  (I), 
  889.         depending  on  how  the loop is  implemented.  These  conventions 
  890.         should cover all aspects of structured program design.   If  your 
  891.         program  cannot  be defined in these terms, it  probably  is  not 
  892.         structured  correctly.   Figure  1.7 shows  a  typical  flowchart 
  893.         commonly  met when dissecting programs written in BASIC.  As  you 
  894.         can  see  it  contains two joined loops  that  cannot  easily  be 
  895.         expressed  using  the  convention  described  above.   It  is  an 
  896.         unstructured  example  of  the  unrestricted  use  of  the   GOTO 
  897.         statement available in the BASIC language.  This type of  program 
  898.         is usually a result of programming at the keyboard without  prior 
  899.         thought.
  900.  
  901.              When  using  this convention for writing flowcharts,  it  is 
  902.         desirable to have some method of indicating the start and  finish 
  903.         of  a  procedure.   Let us use the ":"  (colon)  to  signify  the 
  904.         beginning of a procedure, and the ";" (semi-colon) to signify the 
  905.         end  of the procedure.  This convention will make learning  other 
  906.         computer languages easier later on in your programming career.
  907.  
  908.              It  is also advisable to split the flow chart for a  program 
  909.         into a number of smaller flow charts each explaining a  different 
  910.         section of the program.  Consider the flow charts shown in figure 
  911.         1.8  for the operation of reading a book.  The whole program  can 
  912.         be explained by figure 1.8a as
  913.  
  914.         : READING.A.BOOK
  915.         READ.THE.BOOK ;
  916.  
  917.  
  918.  
  919.         Copyright (c) Joe Kasser 1989
  920.  
  921.  
  922.  
  923.  
  924.  
  925.         Chapter1 page 15 STARTREK THE COMPUTER PROGRAM By Joe Kasser
  926.  
  927.  
  928.         Obviously,  this means very little so we now have to explain  how 
  929.         the  procedure is carried out.   This is shown in figure 1.8b  as 
  930.         follows
  931.  
  932.         : READ.THE.BOOK
  933.         GET.THE.BOOK
  934.         OPEN.THE.BOOK.AT.THE.DESIRED.PAGE
  935.         READ.THE.PAGES
  936.         PUT.IT.AWAY.AGAIN ;
  937.  
  938.         not bad, now let's take a look at how the pages are read as shown 
  939.         in figure 1.8c
  940.  
  941.         : READ.THE.PAGES
  942.         LOOP (Till all pages are read)
  943.         +    READ.SOMETHING.FROM.THE.PAGE
  944.         +    WHOLE.PAGE.READ =?
  945.         +    YES  (1)  END.OF.DESIRED.SECTION.OF.BOOK =?
  946.         +              YES  (2)  SET.END.OF.LOOP.FLAG
  947.         +              NO   (2)  TIME.TO.TURN.PAGE =?
  948.         +                        YES  (3)  TURN.THE.PAGE
  949.         +                        THEN (3)  
  950.         +              THEN  (2) START.AT.THE.TOP.OF.THE.NEXT.PAGE
  951.         +    THEN (1)  
  952.         LOOPEND ;
  953.  
  954.              Each  step is described in words.  The "." (period)  between 
  955.         words  in the description of the procedure signify that a  single 
  956.         phrase  is  being used in the description.  If spaces  were  used 
  957.         confusion could arise from time to time. Comments can be enclosed 
  958.         in  paretheses "(" and ")".  When such a chart is converted to  a 
  959.         program,  the  labels or line numbers in the  program  associated 
  960.         with  the  statements  in  the flowchart  can  be  added  to  the 
  961.         flowchart to make cross referencing easy.  
  962.  
  963.              There  has been no discussion as to exactly how the loop  is 
  964.         implemented.   That  will  depend  on what  the  loop  is  doing.  
  965.         Different  methods of implementing loops will be discussed  later 
  966.         during the course of the book.
  967.  
  968.              Programming
  969.  
  970.              Programming  a  computer is done in three stages.    In  the 
  971.         first   stage  the  action  of  the  program  is  defined.    The 
  972.         specification  is  written,  the flow charts are  drawn  and  the 
  973.         structure  of the program is laid out.  The flow charts are  then 
  974.         converted to programming language statements in the second stage.   
  975.         Once  the program is written the third stage involving  the  test 
  976.         and debugging occurs.
  977.  
  978.              Good  programmers  spend a lot of time performing  stage  1. 
  979.         They  define everything that has to be done by the  program,  and 
  980.         how  it is to do the job.  The coding process does not  take  too 
  981.         long.   The  actual time that it takes is usually a  function  of 
  982.         your typing speed.  The test and debugging phase should not  take 
  983.  
  984.  
  985.         Copyright (c) Joe Kasser 1989
  986.  
  987.  
  988.  
  989.  
  990.  
  991.         Chapter1 page 16 STARTREK THE COMPUTER PROGRAM By Joe Kasser
  992.  
  993.  
  994.         too long if the program is well defined and the whole task to  be 
  995.         performed  is  well understood.   Programmers  that  spend  hours 
  996.         working  on  their own code at the terminal  correcting  one  bug 
  997.         after an other are not "hot shot" programmers, but rather are the 
  998.         reverse.
  999.  
  1000.         1.5 Bugs
  1001.  
  1002.              Errors  in programs are called bugs.  It is inevitable  that 
  1003.         errors will occur during the process of specifying,  flowcharting 
  1004.         and  writing  the  program.  These bugs fall  mostly  into  three 
  1005.         categories as follows.
  1006.  
  1007.         1.5.1 Design Errors
  1008.  
  1009.              Design   errors   are   errors   made   when   turning   the 
  1010.         specifications  for the program into the flowchart.  This  is  an 
  1011.         example of the computer doing what you tell it to do not what you 
  1012.         wanted  it  to  do, because a mistake was made  even  before  the 
  1013.         program was written.
  1014.  
  1015.         1.5.2 Implementation Errors
  1016.  
  1017.              Implementation  errors  are made when the  flow  charts  are 
  1018.         converted to program statements.   These errors are also examples 
  1019.         of  the  computer doing what it is told  to  do.   Implementation 
  1020.         errors  also include forgetting to tell the  computer  something, 
  1021.         such  as not defining a memory location in an  assembly  language 
  1022.         program, or incorrectly writing a PASCAL procedure.
  1023.  
  1024.         1.5.3 Typographical Errors
  1025.  
  1026.              Typographical errors are made when entering the program into 
  1027.         the  computer.  They are usually the easiest to find because  the 
  1028.         computer  can  detect  most of them.   For example,  if  you  are 
  1029.         programming in BASIC and you get
  1030.  
  1031.                        SYNTAX ERROR IN LINE 200 
  1032.  
  1033.         the BASIC interpreter telling you that you have made some sort of 
  1034.         a  typographical  error in line 200.   If however, you  type  the 
  1035.         wrong  symbol for a variable, such as A0 instead of A1, what  you 
  1036.         have  done  is typed in A0 when you meant to enter A1.   This  is 
  1037.         perfectly  valid as far as the computer is concerned.  It  didn't 
  1038.         know what you wanted, it only knows what you tell it.  This  kind 
  1039.         of typographical error falls into the category of  implementation 
  1040.         errors.
  1041.  
  1042.  
  1043.  
  1044.  
  1045.  
  1046.  
  1047.  
  1048.  
  1049.  
  1050.  
  1051.         Copyright (c) Joe Kasser 1989
  1052.  
  1053.  
  1054.  
  1055.  
  1056.  
  1057.